import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import '../../../lib_baseview/widget/textfield/jr_edit_text.dart';
import '../../../resource/language/generated/l10n.dart';

class RoomDialogUtils {
  static showNoValidCarDialog(
      {required BuildContext context, String? tittle, String? tittle2}) {
    String finalTitle = tittle ?? T.current.get_car;
    String finalTitle2 = tittle2 ?? T.current.car_exp_tips;

    _showNormalDialog(
        context: context,
        widget: Container(
            // margin: EdgeInsets.symmetric(horizontal: 48.w),
            color: Colors.transparent,
            child: Column(
              mainAxisSize: MainAxisSize.min,
              children: [
                Container(
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(16.w),
                    color: Colors.white,
                  ),
                  child: Container(
                    decoration: BoxDecoration(
                        borderRadius: BorderRadius.circular(16.w),
                        color: Colors.white
                        // gradient: LinearGradient(
                        //     colors: [Color(0x19FFD400), Color(0x0FFD400)]),
                        ),
                    child: Column(
                      mainAxisSize: MainAxisSize.min,
                      children: [
                        SizedBox(
                          height: 36.h,
                        ),
                        Text(
                          finalTitle,
                          style: TextStyle(
                            fontSize: 18,
                            fontWeight: FontWeight.w600,
                            color: Color(0xff333333),
                          ),
                        ),
                        SizedBox(
                          height: 12.h,
                        ),
                        Padding(
                          padding: EdgeInsets.symmetric(horizontal: 30.w),
                          child: Text(
                            finalTitle2,
                            textAlign: TextAlign.center,
                            style: TextStyle(
                              fontSize: 14,
                              fontWeight: FontWeight.w400,
                              color: Color(0xff666666),
                              height: 22 / 14,
                            ),
                          ),
                        ),
                        SizedBox(
                          height: 24.h,
                        ),
                        Image.asset(
                          "assets/images/ic_room_car_demo.png",
                          fit: BoxFit.contain,
                          width: 160.w,
                          height: 101.w,
                        ),
                        SizedBox(
                          height: 24.h,
                        ),
                        JRButton(
                            title: T.current!.get_now,
                            margin: EdgeInsets.symmetric(horizontal: 24.h),
                            onPressed: () {
                              // BlindBoxMainPage.show(refer: "room");
                            }),
                        // FutureBuilder<BaseRspResult<UserInfoRsp>>(
                        //   builder: (c, snapshot) {
                        //     if (snapshot.connectionState ==
                        //         ConnectionState.done) {
                        //       if (snapshot.hasData &&
                        //           snapshot.data!.data!.user.openedBlindBox) {
                        //         return Column(
                        //           mainAxisSize: MainAxisSize.min,
                        //           children: [
                        //             SizedBox(
                        //               height: 20.h,
                        //             ),
                        //             GestureDetector(
                        //               child: Row(
                        //                 mainAxisSize: MainAxisSize.min,
                        //                 children: [
                        //                   Text(
                        //                     T.current!.look_car_in_bag,
                        //                     style: TextStyle(
                        //                         color: Color(0xFFFFD400),
                        //                         fontSize: 14,
                        //                         fontWeight: FontWeight.w500),
                        //                   ),
                        //                   Icon(
                        //                     Icons.keyboard_arrow_right,
                        //                     color: Color(0xFFFFD400),
                        //                   ),
                        //                 ],
                        //               ),
                        //               onTap: () {
                        //                 Navigator.of(context).push(
                        //                     CupertinoPageRoute(
                        //                         builder: (context) {
                        //                   return const MineCarsPage();
                        //                 }));
                        //               },
                        //             ),
                        //           ],
                        //         );
                        //       }
                        //       return Container();
                        //     }
                        //     return const SizedBox.shrink();
                        //   },
                        //   future: UserApi.instance.getUserInfo(),
                        // ),
                        SizedBox(
                          height: 32.h,
                        ),
                      ],
                    ),
                  ),
                ),
                Container(
                  height: 20.h,
                  // color: Colors.black,
                ),
                CupertinoButton(
                  onPressed: () {
                    Navigator.pop(context);
                  },
                  // color: Colors.black,
                  minSize: 0,
                  padding: EdgeInsets.zero,
                  child: Image.asset(
                    "assets/images/ic_close.png",
                    width: 24.h,
                    height: 24.h,
                  ),
                ),
              ],
            )));
  }

  static _showNormalDialog({
    required BuildContext context,
    required Widget widget,
    double borderRadius = 16,
    bool barrierDismissible = false,
  }) {
    showDialog(
        context: context,
        barrierDismissible: barrierDismissible,
        // barrierColor: Colors.transparent,
        useRootNavigator: false,
        builder: (_) {
          return Dialog(
              shape: RoundedRectangleBorder(
                  borderRadius: BorderRadius.circular(16.w)),
              shadowColor: Colors.transparent,
              backgroundColor: Colors.transparent,
              insetPadding: EdgeInsets.symmetric(horizontal: 48.w),
              child: widget);
        });
  }
}
